﻿namespace HRM.CORE
{
    using DevExpress.Utils;
    using DevExpress.XtraEditors;
    using DevExpress.XtraEditors.Controls;
    using Microsoft.VisualBasic;
    using APP.HELPER;
    using HRM.CORE;
    using System; using Extra.ERP;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Runtime.CompilerServices;
    using System.Windows.Forms; using Common;
    using Dictionary.ERP;
    using Common.Class;
    using Extra.ERP;

    public class xucTimekeepingAdd : Common.xucBaseAddH
    {
        private SimpleButton bbiTimekeepingBreak;
        private SimpleButton bbiTimekeepingExtra;
        private SimpleButton bbiTimekeepingPrivate;
        private SimpleButton btShiftBack;
        private SimpleButton btShiftNext;
        private CalcEdit calDayHour;
        private CalcEdit calEarlyMinute;
        private CalcEdit calHour;
        private CalcEdit calLateMinute;
        private CalcEdit calNightHour;
        private IContainer components = null;
        private DataTable dt_Shift = new DataTable();
        private DateEdit dtDate;
        private FlowLayoutPanel flowLayoutPanel1;
        private GroupControl groupControl1;
        private DevExpress.Utils.ImageCollection imageCollection1;
        private LabelControl labelControl1;
        private LabelControl labelControl10;
        private LabelControl labelControl11;
        private LabelControl labelControl2;
        private LabelControl labelControl3;
        private LabelControl labelControl4;
        private LabelControl labelControl5;
        private LabelControl labelControl6;
        private LabelControl labelControl7;
        private LabelControl labelControl8;
        private LabelControl labelControl9;
        private DateTime m_Date;
        private string m_EmployeeCode;
        private bool m_IsFirstLoad = true;
        private bool m_IsOverTime;
        private bool m_IsWork;
        private int m_Length;
        private string m_ShiftCode;
        private int m_ShiftIndex = 0;
        private int m_ShiftTotal = 0;
        private int m_Sorted;
        private string m_Symbol;
        private Guid m_TimeKeeperTableListID;
        private TimeEdit teTimeIn;
        private TimeEdit teTimeOut;
        private MemoEdit txtDescription;
        private TextEdit txtShift;
        private TextEdit txtSymbol;

        public event SuccessEventHander Success;

        public xucTimekeepingAdd()
        {
            this.InitializeComponent();
        }

        protected override void Add()
        {
            base.Add();
        }

        private void bbiTimekeepingBreak_Click(object sender, EventArgs e)
        {
            xfmTimekeepingBreak @break = new xfmTimekeepingBreak(this.m_TimeKeeperTableListID, this.m_EmployeeCode, this.m_ShiftCode, this.m_Date);
            @break.Updated += delegate (object s, HRM_TIMEKEEPER_BREAK i) {
                this.CalculateHour();
                this.uc_Update();
            };
            @break.Added += delegate (object s, HRM_TIMEKEEPER_BREAK i) {
                this.CalculateHour();
                this.uc_Update();
            };
            @break.Deleted += delegate (object s, RowClickEventArgs i) {
                this.CalculateHour();
                this.uc_Update();
            };
            @break.ShowDialog();
        }

        private void bbiTimekeepingExtra_Click(object sender, EventArgs e)
        {
            xfmTimekeepingExtra extra = new xfmTimekeepingExtra(this.m_TimeKeeperTableListID, this.m_EmployeeCode, this.m_ShiftCode, this.m_Date);
            extra.Updated += delegate (object s, HRM_TIMEKEEPER_EXTRA i) {
                this.CalculateHour();
                this.uc_Update();
            };
            extra.Added += delegate (object s, HRM_TIMEKEEPER_EXTRA i) {
                this.CalculateHour();
                this.uc_Update();
            };
            extra.Deleted += delegate (object s, RowClickEventArgs i) {
                this.CalculateHour();
                this.uc_Update();
            };
            extra.ShowDialog();
        }

        private void bbiTimekeepingPrivate_Click(object sender, EventArgs e)
        {
            xfmTimekeepingPrivate @private = new xfmTimekeepingPrivate(this.m_TimeKeeperTableListID, this.m_EmployeeCode, this.m_ShiftCode, this.m_Date);
            @private.Updated += delegate (object s, HRM_TIMEKEEPER_PRIVATE i) {
                this.CalculateHour();
                this.uc_Update();
            };
            @private.Added += delegate (object s, HRM_TIMEKEEPER_PRIVATE i) {
                this.CalculateHour();
                this.uc_Update();
            };
            @private.Deleted += delegate (object s, RowClickEventArgs i) {
                this.CalculateHour();
                this.uc_Update();
            };
            @private.ShowDialog();
        }

        private void btShiftBack_Click(object sender, EventArgs e)
        {
            HRM_TIMEKEEPER hrm_timekeeper = new HRM_TIMEKEEPER();
            if ((this.m_ShiftIndex - 1) < 1)
            {
                this.m_ShiftIndex = this.m_ShiftTotal;
            }
            else
            {
                this.m_ShiftIndex--;
            }
            DataTable table = hrm_timekeeper.GetListByShift(this.m_TimeKeeperTableListID, this.m_EmployeeCode, this.dt_Shift.Rows[this.m_ShiftIndex - 1]["ShiftCode"].ToString(), this.m_Date);
            this.SetData(table);
        }

        private void btShiftNext_Click(object sender, EventArgs e)
        {
            HRM_TIMEKEEPER hrm_timekeeper = new HRM_TIMEKEEPER();
            if ((this.m_ShiftIndex + 1) > this.m_ShiftTotal)
            {
                this.m_ShiftIndex = 1;
            }
            else
            {
                this.m_ShiftIndex++;
            }
            DataTable table = hrm_timekeeper.GetListByShift(this.m_TimeKeeperTableListID, this.m_EmployeeCode, this.dt_Shift.Rows[this.m_ShiftIndex - 1]["ShiftCode"].ToString(), this.m_Date);
            this.SetData(table);
        }

        private void CalculateHour()
        {
            HRM_TIMEKEEPER hrm_timekeeper = new HRM_TIMEKEEPER();
            hrm_timekeeper.Get(this.m_TimeKeeperTableListID, this.m_EmployeeCode, this.m_ShiftCode, this.m_Symbol, this.m_Date, Convert.ToDateTime(this.teTimeIn.EditValue.ToString()), Convert.ToDateTime(this.teTimeOut.EditValue.ToString()), this.m_Sorted, this.m_Length);
            this.calHour.EditValue = hrm_timekeeper.Hour;
            this.calDayHour.EditValue = hrm_timekeeper.DayHour;
            this.calNightHour.EditValue = hrm_timekeeper.NightHour;
            this.calLateMinute.EditValue = hrm_timekeeper.LateMinute;
            this.calEarlyMinute.EditValue = hrm_timekeeper.EarlyMinute;
        }

        protected override void Dispose(bool disposing)
        {
            if (disposing && (this.components != null))
            {
                this.components.Dispose();
            }
            base.Dispose(disposing);
        }

        protected override void Init()
        {
            base.Init();
        }

        private HRM_TIMEKEEPER InitClass()
        {
            return new HRM_TIMEKEEPER { TimeKeeperTableListID = this.m_TimeKeeperTableListID, EmployeeCode = this.m_EmployeeCode, ShiftCode = this.m_ShiftCode, Date = this.m_Date, Symbol = this.m_Symbol, TimeIn = Convert.ToDateTime(this.teTimeIn.EditValue.ToString()), TimeOut = Convert.ToDateTime(this.teTimeOut.EditValue.ToString()), Hour = Convert.ToDouble(this.calHour.EditValue.ToString()), DayHour = Convert.ToDouble(this.calDayHour.EditValue.ToString()), NightHour = Convert.ToDouble(this.calNightHour.EditValue.ToString()), LateMinute = Convert.ToInt32(this.calLateMinute.EditValue.ToString()), EarlyMinute = Convert.ToInt32(this.calEarlyMinute.EditValue.ToString()), IsOverTime = this.m_IsOverTime, IsWork = this.m_IsWork, Sorted = this.m_Sorted, Description = this.txtDescription.Text };
        }

        private void InitializeComponent()
        {
            this.components = new Container();
            ComponentResourceManager manager = new ComponentResourceManager(typeof(xucTimekeepingAdd));
            this.txtShift = new TextEdit();
            this.labelControl1 = new LabelControl();
            this.labelControl2 = new LabelControl();
            this.dtDate = new DateEdit();
            this.teTimeIn = new TimeEdit();
            this.teTimeOut = new TimeEdit();
            this.labelControl3 = new LabelControl();
            this.labelControl4 = new LabelControl();
            this.calHour = new CalcEdit();
            this.calLateMinute = new CalcEdit();
            this.labelControl5 = new LabelControl();
            this.labelControl6 = new LabelControl();
            this.groupControl1 = new GroupControl();
            this.btShiftNext = new SimpleButton();
            this.btShiftBack = new SimpleButton();
            this.labelControl11 = new LabelControl();
            this.labelControl10 = new LabelControl();
            this.calDayHour = new CalcEdit();
            this.calNightHour = new CalcEdit();
            this.flowLayoutPanel1 = new FlowLayoutPanel();
            this.labelControl9 = new LabelControl();
            this.labelControl8 = new LabelControl();
            this.labelControl7 = new LabelControl();
            this.calEarlyMinute = new CalcEdit();
            this.txtSymbol = new TextEdit();
            this.txtDescription = new MemoEdit();
            this.bbiTimekeepingBreak = new SimpleButton();
            this.imageCollection1 = new DevExpress.Utils.ImageCollection(this.components);
            this.bbiTimekeepingExtra = new SimpleButton();
            this.bbiTimekeepingPrivate = new SimpleButton();
            ((ISupportInitialize) base.Err).BeginInit();
            base.imageCollection2.BeginInit();
            this.txtShift.Properties.BeginInit();
            this.dtDate.Properties.VistaTimeProperties.BeginInit();
            this.dtDate.Properties.BeginInit();
            this.teTimeIn.Properties.BeginInit();
            this.teTimeOut.Properties.BeginInit();
            this.calHour.Properties.BeginInit();
            this.calLateMinute.Properties.BeginInit();
            this.groupControl1.BeginInit();
            this.groupControl1.SuspendLayout();
            this.calDayHour.Properties.BeginInit();
            this.calNightHour.Properties.BeginInit();
            this.calEarlyMinute.Properties.BeginInit();
            this.txtSymbol.Properties.BeginInit();
            this.txtDescription.Properties.BeginInit();
            this.imageCollection1.BeginInit();
            base.SuspendLayout();
            base.btnSave.Anchor = AnchorStyles.Right | AnchorStyles.Bottom;
            base.btnSave.Location = new Point(0xf7, 270);
            base.btnSave.Size = new Size(0x5f, 0x1b);
            base.btnCancel.Anchor = AnchorStyles.Right | AnchorStyles.Bottom;
            base.btnCancel.Location = new Point(0x15c, 270);
            base.btnCancel.Size = new Size(0x45, 0x1b);
            base.btnSaveNew.Anchor = AnchorStyles.Right | AnchorStyles.Bottom;
            base.btnSaveNew.Location = new Point(0xf7, 270);
            base.imageCollection2.ImageStream = (ImageCollectionStreamer) manager.GetObject("imageCollection2.ImageStream");
            this.txtShift.Location = new Point(0x52, 0x20);
            this.txtShift.Name = "txtShift";
            this.txtShift.Properties.Appearance.Font = new Font("Tahoma", 8.25f, FontStyle.Bold);
            this.txtShift.Properties.Appearance.Options.UseFont = true;
            this.txtShift.Properties.ReadOnly = true;
            this.txtShift.Size = new Size(80, 20);
            this.txtShift.TabIndex = 0x26;
            this.labelControl1.Location = new Point(15, 0x23);
            this.labelControl1.Name = "labelControl1";
            this.labelControl1.Size = new Size(0x3a, 13);
            this.labelControl1.TabIndex = 0x27;
            this.labelControl1.Text = "Ca l\x00e0m việc:";
            this.labelControl2.Location = new Point(0xeb, 0x22);
            this.labelControl2.Name = "labelControl2";
            this.labelControl2.Size = new Size(0x1d, 13);
            this.labelControl2.TabIndex = 40;
            this.labelControl2.Text = "Ng\x00e0y:";
            this.dtDate.EditValue = null;
            this.dtDate.Location = new Point(0x113, 0x20);
            this.dtDate.Name = "dtDate";
            this.dtDate.Properties.Buttons.AddRange(new EditorButton[] { new EditorButton(ButtonPredefines.Combo) });
            this.dtDate.Properties.ReadOnly = true;
            this.dtDate.Properties.VistaTimeProperties.Buttons.AddRange(new EditorButton[] { new EditorButton() });
            this.dtDate.Size = new Size(0x8e, 20);
            this.dtDate.TabIndex = 0x29;
            this.teTimeIn.EditValue = new DateTime(0x7dd, 6, 1, 0, 0, 0, 0);
            this.teTimeIn.Location = new Point(0x52, 0x42);
            this.teTimeIn.Name = "teTimeIn";
            this.teTimeIn.Properties.Buttons.AddRange(new EditorButton[] { new EditorButton() });
            this.teTimeIn.Properties.Mask.EditMask = "HH:mm tt dd/MM/yyyy";
            this.teTimeIn.Size = new Size(0x8f, 20);
            this.teTimeIn.TabIndex = 0x2a;
            this.teTimeIn.ParseEditValue += new ConvertEditValueEventHandler(this.teTimeIn_ParseEditValue);
            this.teTimeOut.EditValue = new DateTime(0x7dd, 6, 1, 0, 0, 0, 0);
            this.teTimeOut.Location = new Point(0x113, 0x42);
            this.teTimeOut.Name = "teTimeOut";
            this.teTimeOut.Properties.Buttons.AddRange(new EditorButton[] { new EditorButton() });
            this.teTimeOut.Properties.Mask.EditMask = "HH:mm tt dd/MM/yyyy";
            this.teTimeOut.Size = new Size(0x8e, 20);
            this.teTimeOut.TabIndex = 0x2b;
            this.teTimeOut.ParseEditValue += new ConvertEditValueEventHandler(this.teTimeIn_ParseEditValue);
            this.labelControl3.Location = new Point(15, 0x45);
            this.labelControl3.Name = "labelControl3";
            this.labelControl3.Size = new Size(0x33, 13);
            this.labelControl3.TabIndex = 0x2c;
            this.labelControl3.Text = "Giờ đi v\x00e0o:";
            this.labelControl4.Location = new Point(230, 0x45);
            this.labelControl4.Name = "labelControl4";
            this.labelControl4.Size = new Size(0x2b, 13);
            this.labelControl4.TabIndex = 0x2d;
            this.labelControl4.Text = "Giờ đi ra:";
            this.calHour.Location = new Point(0x53, 100);
            this.calHour.Name = "calHour";
            this.calHour.Properties.Buttons.AddRange(new EditorButton[] { new EditorButton(ButtonPredefines.Combo) });
            this.calHour.Properties.ReadOnly = true;
            this.calHour.Size = new Size(0x4f, 20);
            this.calHour.TabIndex = 0x2e;
            this.calLateMinute.Location = new Point(0xde, 0x98);
            this.calLateMinute.Name = "calLateMinute";
            this.calLateMinute.Properties.Buttons.AddRange(new EditorButton[] { new EditorButton(ButtonPredefines.Combo) });
            this.calLateMinute.Properties.ReadOnly = true;
            this.calLateMinute.Size = new Size(0x41, 20);
            this.calLateMinute.TabIndex = 0x2f;
            this.labelControl5.Location = new Point(13, 0x67);
            this.labelControl5.Name = "labelControl5";
            this.labelControl5.Size = new Size(0x3b, 13);
            this.labelControl5.TabIndex = 0x30;
            this.labelControl5.Text = "Tổng số giờ:";
            this.labelControl6.Location = new Point(0xb9, 0x9b);
            this.labelControl6.Name = "labelControl6";
            this.labelControl6.Size = new Size(0x1f, 13);
            this.labelControl6.TabIndex = 0x31;
            this.labelControl6.Text = "Đi trể:";
            this.groupControl1.Controls.Add(this.btShiftNext);
            this.groupControl1.Controls.Add(this.btShiftBack);
            this.groupControl1.Controls.Add(this.labelControl11);
            this.groupControl1.Controls.Add(this.labelControl10);
            this.groupControl1.Controls.Add(this.calDayHour);
            this.groupControl1.Controls.Add(this.calNightHour);
            this.groupControl1.Controls.Add(this.flowLayoutPanel1);
            this.groupControl1.Controls.Add(this.labelControl9);
            this.groupControl1.Controls.Add(this.labelControl8);
            this.groupControl1.Controls.Add(this.labelControl7);
            this.groupControl1.Controls.Add(this.calEarlyMinute);
            this.groupControl1.Controls.Add(this.labelControl1);
            this.groupControl1.Controls.Add(this.txtShift);
            this.groupControl1.Controls.Add(this.txtSymbol);
            this.groupControl1.Controls.Add(this.labelControl6);
            this.groupControl1.Controls.Add(this.labelControl2);
            this.groupControl1.Controls.Add(this.labelControl5);
            this.groupControl1.Controls.Add(this.dtDate);
            this.groupControl1.Controls.Add(this.calLateMinute);
            this.groupControl1.Controls.Add(this.teTimeIn);
            this.groupControl1.Controls.Add(this.calHour);
            this.groupControl1.Controls.Add(this.teTimeOut);
            this.groupControl1.Controls.Add(this.labelControl4);
            this.groupControl1.Controls.Add(this.labelControl3);
            this.groupControl1.Controls.Add(this.txtDescription);
            this.groupControl1.Dock = DockStyle.Top;
            this.groupControl1.Location = new Point(0, 0);
            this.groupControl1.Name = "groupControl1";
            this.groupControl1.Size = new Size(0x1af, 260);
            this.groupControl1.TabIndex = 0x33;
            this.groupControl1.Text = "Th\x00f4ng Tin Ra/V\x00e0o";
            this.btShiftNext.Enabled = false;
            this.btShiftNext.Location = new Point(0xc4, 0x20);
            this.btShiftNext.Name = "btShiftNext";
            this.btShiftNext.Size = new Size(0x1c, 20);
            this.btShiftNext.TabIndex = 60;
            this.btShiftNext.Text = ">";
            this.btShiftNext.Click += new EventHandler(this.btShiftNext_Click);
            this.btShiftBack.Enabled = false;
            this.btShiftBack.Location = new Point(0xa6, 0x20);
            this.btShiftBack.Name = "btShiftBack";
            this.btShiftBack.Size = new Size(0x1c, 20);
            this.btShiftBack.TabIndex = 0x3b;
            this.btShiftBack.Text = "<";
            this.btShiftBack.Click += new EventHandler(this.btShiftBack_Click);
            this.labelControl11.Location = new Point(0xa8, 0x67);
            this.labelControl11.Name = "labelControl11";
            this.labelControl11.Size = new Size(0x2e, 13);
            this.labelControl11.TabIndex = 0x3a;
            this.labelControl11.Text = "Ng\x00e0y (h):";
            this.labelControl10.Location = new Point(0x12b, 0x67);
            this.labelControl10.Name = "labelControl10";
            this.labelControl10.Size = new Size(0x2b, 13);
            this.labelControl10.TabIndex = 0x3a;
            this.labelControl10.Text = "Đ\x00eam (h):";
            this.calDayHour.Location = new Point(220, 100);
            this.calDayHour.Name = "calDayHour";
            this.calDayHour.Properties.Buttons.AddRange(new EditorButton[] { new EditorButton(ButtonPredefines.Combo) });
            this.calDayHour.Properties.ReadOnly = true;
            this.calDayHour.Size = new Size(0x43, 20);
            this.calDayHour.TabIndex = 0x39;
            this.calNightHour.Location = new Point(0x15c, 100);
            this.calNightHour.Name = "calNightHour";
            this.calNightHour.Properties.Buttons.AddRange(new EditorButton[] { new EditorButton(ButtonPredefines.Combo) });
            this.calNightHour.Properties.ReadOnly = true;
            this.calNightHour.Size = new Size(0x45, 20);
            this.calNightHour.TabIndex = 0x39;
            this.flowLayoutPanel1.Location = new Point(0x52, 0xe5);
            this.flowLayoutPanel1.Name = "flowLayoutPanel1";
            this.flowLayoutPanel1.RightToLeft = RightToLeft.Yes;
            this.flowLayoutPanel1.Size = new Size(0x150, 0x18);
            this.flowLayoutPanel1.TabIndex = 0x38;
            this.labelControl9.Location = new Point(15, 0xbb);
            this.labelControl9.Name = "labelControl9";
            this.labelControl9.Size = new Size(0x27, 13);
            this.labelControl9.TabIndex = 0x37;
            this.labelControl9.Text = "Ghi ch\x00fa:";
            this.labelControl8.Appearance.Options.UseTextOptions = true;
            this.labelControl8.Appearance.TextOptions.WordWrap = WordWrap.Wrap;
            this.labelControl8.Location = new Point(15, 0x85);
            this.labelControl8.Name = "labelControl8";
            this.labelControl8.Size = new Size(0x5d, 13);
            this.labelControl8.TabIndex = 0x35;
            this.labelControl8.Text = "K\x00fd hiệu chấm c\x00f4ng:";
            this.labelControl7.Location = new Point(0x130, 0x9b);
            this.labelControl7.Name = "labelControl7";
            this.labelControl7.Size = new Size(0x26, 13);
            this.labelControl7.TabIndex = 0x33;
            this.labelControl7.Text = "Về sớm:";
            this.calEarlyMinute.Location = new Point(0x15c, 0x98);
            this.calEarlyMinute.Name = "calEarlyMinute";
            this.calEarlyMinute.Properties.Buttons.AddRange(new EditorButton[] { new EditorButton(ButtonPredefines.Combo) });
            this.calEarlyMinute.Properties.ReadOnly = true;
            this.calEarlyMinute.Size = new Size(0x45, 20);
            this.calEarlyMinute.TabIndex = 50;
            this.txtSymbol.Location = new Point(0x52, 0x98);
            this.txtSymbol.Name = "txtSymbol";
            this.txtSymbol.Properties.Appearance.Font = new Font("Tahoma", 8.25f, FontStyle.Bold);
            this.txtSymbol.Properties.Appearance.Options.UseFont = true;
            this.txtSymbol.Properties.ReadOnly = true;
            this.txtSymbol.Size = new Size(80, 20);
            this.txtSymbol.TabIndex = 0x34;
            this.txtSymbol.TabStop = false;
            this.txtDescription.Location = new Point(0x52, 0xb9);
            this.txtDescription.Name = "txtDescription";
            this.txtDescription.Size = new Size(0x150, 0x26);
            this.txtDescription.TabIndex = 0x36;
            this.txtDescription.TabStop = false;
            this.bbiTimekeepingBreak.Anchor = AnchorStyles.Left | AnchorStyles.Bottom;
            this.bbiTimekeepingBreak.ButtonStyle = BorderStyles.Simple;
            this.bbiTimekeepingBreak.ImageIndex = 0;
            this.bbiTimekeepingBreak.ImageList = this.imageCollection1;
            this.bbiTimekeepingBreak.Location = new Point(13, 270);
            this.bbiTimekeepingBreak.Name = "bbiTimekeepingBreak";
            this.bbiTimekeepingBreak.Size = new Size(60, 0x1b);
            this.bbiTimekeepingBreak.TabIndex = 0x34;
            this.bbiTimekeepingBreak.Text = "(0h)";
            this.bbiTimekeepingBreak.ToolTip = "Ra V\x00e0o Trong Ca";
            this.bbiTimekeepingBreak.Click += new EventHandler(this.bbiTimekeepingBreak_Click);
            this.imageCollection1.ImageStream = (ImageCollectionStreamer) manager.GetObject("imageCollection1.ImageStream");
            this.imageCollection1.Images.SetKeyName(0, "user_yellow_go.png");
            this.imageCollection1.Images.SetKeyName(1, "RecentContact_Icon.png");
            this.imageCollection1.Images.SetKeyName(2, "RecentContact_Icon (2).png");
            this.imageCollection1.Images.SetKeyName(3, "voice_billing.png");
            this.bbiTimekeepingExtra.Anchor = AnchorStyles.Left | AnchorStyles.Bottom;
            this.bbiTimekeepingExtra.Appearance.ForeColor = Color.Blue;
            this.bbiTimekeepingExtra.Appearance.Options.UseForeColor = true;
            this.bbiTimekeepingExtra.ButtonStyle = BorderStyles.Simple;
            this.bbiTimekeepingExtra.ImageIndex = 1;
            this.bbiTimekeepingExtra.ImageList = this.imageCollection1;
            this.bbiTimekeepingExtra.Location = new Point(0x48, 270);
            this.bbiTimekeepingExtra.Name = "bbiTimekeepingExtra";
            this.bbiTimekeepingExtra.Size = new Size(60, 0x1b);
            this.bbiTimekeepingExtra.TabIndex = 0x3d;
            this.bbiTimekeepingExtra.Text = "(0h)";
            this.bbiTimekeepingExtra.ToolTip = "Tăng Cường Sau Ca L\x00e0m Việc";
            this.bbiTimekeepingExtra.Click += new EventHandler(this.bbiTimekeepingExtra_Click);
            this.bbiTimekeepingPrivate.Anchor = AnchorStyles.Left | AnchorStyles.Bottom;
            this.bbiTimekeepingPrivate.Appearance.ForeColor = Color.FromArgb(0xc0, 0x40, 0);
            this.bbiTimekeepingPrivate.Appearance.Options.UseForeColor = true;
            this.bbiTimekeepingPrivate.ButtonStyle = BorderStyles.Simple;
            this.bbiTimekeepingPrivate.ImageIndex = 2;
            this.bbiTimekeepingPrivate.ImageList = this.imageCollection1;
            this.bbiTimekeepingPrivate.Location = new Point(0x83, 270);
            this.bbiTimekeepingPrivate.Name = "bbiTimekeepingPrivate";
            this.bbiTimekeepingPrivate.Size = new Size(0x3e, 0x1b);
            this.bbiTimekeepingPrivate.TabIndex = 0x3d;
            this.bbiTimekeepingPrivate.Text = "(0h)";
            this.bbiTimekeepingPrivate.ToolTip = "L\x00e0m Việc Ri\x00eang";
            this.bbiTimekeepingPrivate.Click += new EventHandler(this.bbiTimekeepingPrivate_Click);
            base.AutoScaleDimensions = new SizeF(6f, 13f);
            base.AutoScaleMode = AutoScaleMode.Font;
            base.Controls.Add(this.bbiTimekeepingPrivate);
            base.Controls.Add(this.bbiTimekeepingExtra);
            base.Controls.Add(this.bbiTimekeepingBreak);
            base.Controls.Add(this.groupControl1);
            base.Name = "xucTimekeepingAdd";
            base.Size = new Size(0x1af, 0x131);
            base.Controls.SetChildIndex(base.btnCancel, 0);
            base.Controls.SetChildIndex(base.btnSaveNew, 0);
            base.Controls.SetChildIndex(base.btnSave, 0);
            base.Controls.SetChildIndex(this.groupControl1, 0);
            base.Controls.SetChildIndex(this.bbiTimekeepingBreak, 0);
            base.Controls.SetChildIndex(this.bbiTimekeepingExtra, 0);
            base.Controls.SetChildIndex(this.bbiTimekeepingPrivate, 0);
            ((ISupportInitialize) base.Err).EndInit();
            base.imageCollection2.EndInit();
            this.txtShift.Properties.EndInit();
            this.dtDate.Properties.VistaTimeProperties.EndInit();
            this.dtDate.Properties.EndInit();
            this.teTimeIn.Properties.EndInit();
            this.teTimeOut.Properties.EndInit();
            this.calHour.Properties.EndInit();
            this.calLateMinute.Properties.EndInit();
            this.groupControl1.EndInit();
            this.groupControl1.ResumeLayout(false);
            this.groupControl1.PerformLayout();
            this.calDayHour.Properties.EndInit();
            this.calNightHour.Properties.EndInit();
            this.calEarlyMinute.Properties.EndInit();
            this.txtSymbol.Properties.EndInit();
            this.txtDescription.Properties.EndInit();
            this.imageCollection1.EndInit();
            base.ResumeLayout(false);
        }

        private void InitSortedButtonData(DataTable Table)
        {
            this.flowLayoutPanel1.Controls.Clear();
            int num = 1;
            foreach (DataRow row in Table.Rows)
            {
                SimpleButton button = new SimpleButton {
                    Text = row["Symbol"].ToString(),
                    Height = 0x15,
                    Width = 0x20
                };
                button.Click += new EventHandler(this.spButton_Click);
                this.flowLayoutPanel1.Controls.Add(button);
                if (num == Table.Rows.Count)
                {
                    this.SetData(row);
                }
                num++;
            }
            this.m_Length = num - 1;
            this.flowLayoutPanel1.Visible = true;
            this.txtDescription.Height = 0x26;
            if (Table.Rows.Count == 1)
            {
                this.flowLayoutPanel1.Visible = false;
                this.txtDescription.Height = 0x3a;
            }
        }

        private void RaiseSuccessEventHander(HRM_TIMEKEEPER item)
        {
            if (this.Success != null)
            {
                this.Success(this, item);
            }
        }

        public void SetData(HRM_TIMEKEEPER item)
        {
            SYS_LOG.Insert("Giờ L\x00e0m Việc", "Xem", item.ShiftCode.ToString());
            this.m_TimeKeeperTableListID = item.TimeKeeperTableListID;
            this.m_EmployeeCode = item.EmployeeCode;
            HRM_EMPLOYEE hrm_employee = new HRM_EMPLOYEE();
            hrm_employee.Get(this.m_EmployeeCode);
            this.groupControl1.Text = "Th\x00f4ng Tin Ra/V\x00e0o - " + hrm_employee.FirstName + " " + hrm_employee.LastName + " (" + hrm_employee.EmployeeCode + ") - " + item.Symbol;
            this.m_ShiftCode = item.ShiftCode;
            this.m_Date = item.Date;
            this.m_Symbol = item.Symbol;
            DIC_SHIFT dic_shift = new DIC_SHIFT();
            dic_shift.Get(this.m_ShiftCode);
            this.txtShift.Text = dic_shift.ShiftName;
            this.dtDate.DateTime = item.Date;
            this.txtSymbol.Text = item.Symbol;
            this.m_IsFirstLoad = true;
            this.teTimeIn.EditValue = item.TimeIn;
            this.m_IsFirstLoad = true;
            this.teTimeOut.EditValue = item.TimeOut;
            this.calHour.EditValue = item.Hour;
            this.calDayHour.EditValue = item.DayHour;
            this.calNightHour.EditValue = item.NightHour;
            this.calLateMinute.EditValue = item.LateMinute;
            this.calEarlyMinute.EditValue = item.EarlyMinute;
            this.m_IsOverTime = item.IsOverTime;
            this.m_IsWork = item.IsWork;
            this.m_Sorted = item.Sorted;
            this.txtDescription.Text = item.Description;
            double num = new HRM_TIMEKEEPER_BREAK().TotalBreakHour(this.m_TimeKeeperTableListID, this.m_EmployeeCode, this.m_ShiftCode, this.m_Date);
            this.bbiTimekeepingBreak.Text = "(" + num.ToString() + "h)";
            if (num > 0.0)
            {
                this.bbiTimekeepingBreak.ButtonStyle = BorderStyles.Office2003;
            }
            else
            {
                this.bbiTimekeepingBreak.ButtonStyle = BorderStyles.Simple;
            }
            double num2 = new HRM_TIMEKEEPER_EXTRA().TotalExtraHour(this.m_TimeKeeperTableListID, this.m_EmployeeCode, this.m_ShiftCode, this.m_Date);
            this.bbiTimekeepingExtra.Text = "(" + num2.ToString() + "h)";
            if (num2 > 0.0)
            {
                this.bbiTimekeepingExtra.ButtonStyle = BorderStyles.Office2003;
            }
            else
            {
                this.bbiTimekeepingExtra.ButtonStyle = BorderStyles.Simple;
            }
            double num3 = new HRM_TIMEKEEPER_PRIVATE().TotalPrivateHour(this.m_TimeKeeperTableListID, this.m_EmployeeCode, this.m_ShiftCode, this.m_Date);
            this.bbiTimekeepingPrivate.Text = "(" + num3.ToString() + "h)";
            if (num3 > 0.0)
            {
                this.bbiTimekeepingPrivate.ButtonStyle = BorderStyles.Office2003;
            }
            else
            {
                this.bbiTimekeepingPrivate.ButtonStyle = BorderStyles.Simple;
            }
        }

        public void SetData(DataRow dr)
        {
            this.m_TimeKeeperTableListID = new Guid(dr["TimeKeeperTableListID"].ToString());
            this.m_EmployeeCode = dr["EmployeeCode"].ToString();
            HRM_EMPLOYEE hrm_employee = new HRM_EMPLOYEE();
            hrm_employee.Get(this.m_EmployeeCode);
            this.groupControl1.Text = "Th\x00f4ng Tin Ra/V\x00e0o - " + hrm_employee.FirstName + " " + hrm_employee.LastName + " (" + hrm_employee.EmployeeCode + ") - " + dr["Symbol"].ToString();
            this.m_ShiftCode = dr["ShiftCode"].ToString();
            this.m_Date = Convert.ToDateTime(dr["Date"].ToString());
            this.m_Symbol = dr["Symbol"].ToString();
            HRM_TIMEKEEPER item = new HRM_TIMEKEEPER();
            item.Get(this.m_TimeKeeperTableListID, this.m_EmployeeCode, this.m_ShiftCode, this.m_Date, this.m_Symbol);
            this.SetData(item);
        }

        public void SetData(DataTable Table)
        {
            this.InitSortedButtonData(Table);
        }

        public void SetData(Guid TimeKeeperTableListID, string EmployeeCode, DateTime Date)
        {
            HRM_TIMEKEEPER hrm_timekeeper = new HRM_TIMEKEEPER();
            this.dt_Shift = hrm_timekeeper.GetListByDate1(EmployeeCode, Date);
            if (this.dt_Shift.Rows.Count > 1)
            {
                this.btShiftBack.Enabled = true;
                this.btShiftNext.Enabled = true;
                this.bbiTimekeepingBreak.Enabled = true;
                base.btnSave.Enabled = true;
            }
            else if (this.dt_Shift.Rows.Count == 1)
            {
                this.btShiftBack.Enabled = false;
                this.btShiftNext.Enabled = false;
                this.bbiTimekeepingBreak.Enabled = true;
                base.btnSave.Enabled = true;
            }
            else if (this.dt_Shift.Rows.Count < 1)
            {
                this.btShiftBack.Enabled = false;
                this.btShiftNext.Enabled = false;
                this.bbiTimekeepingBreak.Enabled = false;
                base.btnSave.Enabled = false;
                this.txtShift.Text = "";
                this.dtDate.DateTime = DateTime.Now;
                this.teTimeIn.EditValue = DateTime.Now;
                this.teTimeOut.EditValue = DateTime.Now;
                this.calHour.EditValue = 0;
                this.calNightHour.EditValue = 0;
                this.calDayHour.EditValue = 0;
                this.txtSymbol.Text = "";
                this.calLateMinute.EditValue = 0;
                this.calEarlyMinute.EditValue = "";
                this.txtDescription.Text = "";
                return;
            }
            this.m_ShiftIndex = 1;
            this.m_ShiftTotal = this.dt_Shift.Rows.Count;
            DataTable table = hrm_timekeeper.GetListByShift(TimeKeeperTableListID, EmployeeCode, this.dt_Shift.Rows[this.m_ShiftIndex - 1]["ShiftCode"].ToString(), Date);
            this.SetData(table);
        }

        private void spButton_Click(object sender, EventArgs e)
        {
            try
            {
                HRM_TIMEKEEPER item = new HRM_TIMEKEEPER();
                item.Get(this.m_TimeKeeperTableListID, this.m_EmployeeCode, this.m_ShiftCode, this.m_Date, (sender as SimpleButton).Text);
                this.SetData(item);
            }
            catch
            {
            }
        }

        private void teTimeIn_ParseEditValue(object sender, ConvertEditValueEventArgs e)
        {
            if (!this.m_IsFirstLoad)
            {
                this.CalculateHour();
            }
            else
            {
                this.m_IsFirstLoad = false;
            }
        }

        protected override string uc_Change()
        {
            return string.Empty;
        }

        protected override string uc_Delete()
        {
            HRM_TIMEKEEPER item = this.InitClass();
            string str = item.Delete();
            if (str == "OK")
            {
                this.RaiseSuccessEventHander(item);
            }
            return str;
        }

        protected override string uc_Save()
        {
            SYS_LOG.Insert("Giờ L\x00e0m Việc L\x00e0m Việc", "Th\x00eam", "");
            long num = DateAndTime.DateDiff(DateInterval.Hour, Convert.ToDateTime(this.teTimeIn.EditValue.ToString()), Convert.ToDateTime(this.teTimeOut.EditValue.ToString()), FirstDayOfWeek.System, FirstWeekOfYear.System);
            if ((num < 0L) || (num > 0x18L))
            {
                XtraMessageBox.Show("Số giờ kh\x00f4ng được b\x00e9 hơn 0 hoặc lớn hơn 24!", "Th\x00f4ng B\x00e1o", MessageBoxButtons.OK, MessageBoxIcon.Hand);
                return "";
            }
            HRM_TIMEKEEPER item = new HRM_TIMEKEEPER();
            item = this.InitClass();
            if (item == null)
            {
                return "FALSE";
            }
            base.SetWaitDialogCaption("Đang lưu dữ liệu...");
            string text = item.Insert();
            if (text == "OK")
            {
                this.RaiseSuccessEventHander(item);
                new HRM_TIMEKEEPER_TOTAL().Get(this.m_TimeKeeperTableListID, this.m_EmployeeCode);
            }
            Cursor.Current = Cursors.Default;
            if (text != "OK")
            {
                XtraMessageBox.Show(text, "Cảnh B\x00e1o", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
            this.DoHide();
            return text;
        }

        protected override string uc_Update()
        {
            SYS_LOG.Insert("Giờ L\x00e0m Việc", "Cập Nhật", this.m_EmployeeCode.ToString());
            long num = DateAndTime.DateDiff(DateInterval.Hour, Convert.ToDateTime(this.teTimeIn.EditValue.ToString()), Convert.ToDateTime(this.teTimeOut.EditValue.ToString()), FirstDayOfWeek.System, FirstWeekOfYear.System);
            if ((num < 0L) || (num > 0x18L))
            {
                XtraMessageBox.Show("Số giờ kh\x00f4ng được b\x00e9 hơn 0 hoặc lớn hơn 24!", "Th\x00f4ng B\x00e1o", MessageBoxButtons.OK, MessageBoxIcon.Hand);
                return "";
            }
            base.SetWaitDialogCaption("Đang cập nhật dữ liệu...");
            HRM_TIMEKEEPER item = new HRM_TIMEKEEPER();
            item = this.InitClass();
            string text = item.Update();
            if (text == "OK")
            {
                this.RaiseSuccessEventHander(item);
            }
            if (text != "OK")
            {
                XtraMessageBox.Show(text, "Cảnh B\x00e1o", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
            this.DoHide();
            return text;
        }

        public delegate void SuccessEventHander(object sender, HRM_TIMEKEEPER item);
    }
}

